package com.copa.l2180;

/**
 * @author copa
 * @createDate 2023-01-06 10:42
 * @function 常规法
 */
public class Test1 {

    public int countEven(int num) {
        int result = 0;
        if (num > 1) {
            for (int i = 2; i <= num; i++) {
                if (evenNum(i)) {
                    result++;
                }
            }
        }
        return result;
    }

    private boolean evenNum(int num) {
        int temp = 0;
        String s = String.valueOf(num);
        for (int i = 0; i < s.length(); i++) {
            temp += s.charAt(i);
        }
        return temp % 2 == 0;
    }

    public static void main(String[] args) {
        int num = 30;
        System.out.println(new Test1().countEven(num));
    }
}
